package ita.mock.os;

import java.io.IOException;

import javax.servlet.ServletOutputStream;

import org.apache.commons.codec.binary.Base64;

public class Base64ServletOutputStream extends ServletOutputStream {

	private ServletOutputStream sos;
	private Base64 base64=new Base64();
	public void setSos(ServletOutputStream sos) {
		this.sos = sos;
	}

	public Base64ServletOutputStream() {
		super();
	}

	public Base64ServletOutputStream(ServletOutputStream sos) {
		this.sos = sos;
	}

	@Override
	public void write(byte[] b) throws IOException {
		// Base64编码
		System.out.println("base64:"+base64.encode(b));
		sos.write(base64.encode(b));
	}

	@Override
	public void write(int b) throws IOException {
		// TODO Auto-generated method stub
		sos.write(b);
	}

	
}
